package common.util;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * 敏感词
 *
 * @author 米泽鹏
 * @since 2023-9-16 下午 9:24
 */
@Slf4j
public class SensitiveWordUtil {

	/**
	 * 禁止使用的敏感词，用户名和昵称中不可含有，校验合法性时忽略大小写
	 */
	private static final String[] SENSITIVE_WORDS = {
			SecurityConstants.ANONYMOUS_USER,
			"master",
			"主人",
			"admin",
			"管理员",
			Constants.INNER_VISITOR_USERNAME,
			"访客",
			"游客",
			Constants.DELETED_USERNAME_PREFIX,
			Constants.DELETED_NICKNAME_PREFIX
	};

	private SensitiveWordUtil() {
		throw new AssertionError("不可实例化");
	}

	public static String[] getSensitiveWords() {
		return SENSITIVE_WORDS;
	}

	public static boolean isSensitive(String testingStr) {
		return StrUtil.containsAnyIgnoreCase(testingStr, SENSITIVE_WORDS);
	}

}
